<?php

namespace iBrand\Component\Discount\Models;

use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

class SingleDiscountCondition extends Model implements Transformable
{
	use TransformableTrait;

	protected $table = 'el_single_discount_conditions';

	protected $guarded = ['id'];

	public function setValueAttribute($value)
	{
		$this->attributes['value'] = serialize($value);
	}

	public function getValueAttribute($value)
	{
		return unserialize($value);
	}

	public function discount()
	{
		return $this->belongsTo(SingleDiscount::class, 'single_discount_id');
	}

}
